import collections


class Solution:
    def sortArrayByParity(self, A: list) -> list:
        queue = collections.deque()
        for num in A:
            if num % 2 == 0:
                queue.appendleft(num)
            else:
                queue.append(num)

        return list(queue)
